home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / WarpQuake / Src / client.h < prev    next >
C/C++ Source or Header  |  2000-05-22  |  9KB  |  378 lines

  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3.  
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation; either version 2
  7. of the License, or (at your option) any later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  12.  
  13. See the GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. */
  20. // client.h
  21.  
  22. typedef struct
  23. {
  24.     vec3_t    viewangles;
  25.  
  26. // intended velocities
  27.     float    forwardmove;
  28.     float    sidemove;
  29.     float    upmove;
  30. #ifdef QUAKE2
  31.     byte    lightlevel;
  32. #endif
  33. } usercmd_t;
  34.  
  35. typedef struct
  36. {
  37.     int        length;
  38.     char    map[MAX_STYLESTRING];
  39. } lightstyle_t;
  40.  
  41. typedef struct
  42. {
  43.     char    name[MAX_SCOREBOARDNAME];
  44.     float    entertime;
  45.     int        frags;
  46.     int        colors;            // two 4 bit fields
  47.     byte    translations[VID_GRADES*256];
  48. } scoreboard_t;
  49.  
  50. typedef struct
  51. {
  52.     int        destcolor[3];
  53.     int        percent;        // 0-256
  54. } cshift_t;
  55.  
  56. #define    CSHIFT_CONTENTS    0
  57. #define    CSHIFT_DAMAGE    1
  58. #define    CSHIFT_BONUS    2
  59. #define    CSHIFT_POWERUP    3
  60. #define    NUM_CSHIFTS        4
  61.  
  62. #define    NAME_LENGTH    64
  63.  
  64.  
  65. //
  66. // client_state_t should hold all pieces of the client state
  67. //
  68.  
  69. #define    SIGNONS        4            // signon messages to receive before connected
  70.  
  71. #define    MAX_DLIGHTS        32
  72. typedef struct
  73. {
  74.     vec3_t    origin;
  75.     float    radius;
  76.     float    die;                // stop lighting after this time
  77.     float    decay;                // drop this each second
  78.     float    minlight;            // don't add when contributing less
  79.     int        key;
  80. #ifdef QUAKE2
  81.     qboolean    dark;            // subtracts light instead of adding
  82. #endif
  83. } dlight_t;
  84.  
  85.  
  86. #define    MAX_BEAMS    24
  87. typedef struct
  88. {
  89.     int        entity;
  90.     struct model_s    *model;
  91.     float    endtime;
  92.     vec3_t    start, end;
  93. } beam_t;
  94.  
  95. #define    MAX_EFRAGS        640
  96.  
  97. #define    MAX_MAPSTRING    2048
  98. #define    MAX_DEMOS        8
  99. #define    MAX_DEMONAME    16
  100.  
  101. typedef enum {
  102. ca_dedicated,         // a dedicated server with no ability to start a client
  103. ca_disconnected,     // full screen console with no connection
  104. ca_connected        // valid netcon, talking to a server
  105. } cactive_t;
  106.  
  107. //
  108. // the client_static_t structure is persistant through an arbitrary number
  109. // of server connections
  110. //
  111. typedef struct
  112. {
  113.     cactive_t    state;
  114.  
  115. // personalization data sent to server    
  116.     char        mapstring[MAX_QPATH];
  117.     char        spawnparms[MAX_MAPSTRING];    // to restart a level
  118.  
  119. // demo loop control
  120.     int            demonum;        // -1 = don't play demos
  121.     char        demos[MAX_DEMOS][MAX_DEMONAME];        // when not playing
  122.  
  123. // demo recording info must be here, because record is started before
  124. // entering a map (and clearing client_state_t)
  125.     qboolean    demorecording;
  126.     qboolean    demoplayback;
  127.     qboolean    timedemo;
  128.     qboolean    timedemo2;
  129.     int            forcetrack;            // -1 = use normal cd track
  130.     FILE        *demofile;
  131.     int            td_lastframe;        // to meter out one message a frame
  132.     int            td_startframe;        // host_framecount at start
  133.     float        td_starttime;        // realtime at second frame of timedemo
  134.  
  135.  
  136. // connection information
  137.     int            signon;            // 0 to SIGNONS
  138.     struct qsocket_s    *netcon;
  139.     sizebuf_t    message;        // writing buffer to send to server
  140.     
  141. } client_static_t;
  142.  
  143. extern client_static_t    cls;
  144.  
  145. //
  146. // the client_state_t structure is wiped completely at every
  147. // server signon
  148. //
  149. typedef struct
  150. {
  151.     int            movemessages;    // since connecting to this server
  152.                                 // throw out the first couple, so the player
  153.                                 // doesn't accidentally do something the 
  154.                                 // first frame
  155.     usercmd_t    cmd;            // last command sent to the server
  156.  
  157. // information for local display
  158.     int            stats[MAX_CL_STATS];    // health, etc
  159.     int            items;            // inventory bit flags
  160.     float    item_gettime[32];    // cl.time of aquiring item, for blinking
  161.     float        faceanimtime;    // use anim frame if cl.time < this
  162.  
  163.     cshift_t    cshifts[NUM_CSHIFTS];    // color shifts for damage, powerups
  164.     cshift_t    prev_cshifts[NUM_CSHIFTS];    // and content types
  165.  
  166. // the client maintains its own idea of view angles, which are
  167. // sent to the server each frame.  The server sets punchangle when
  168. // the view is temporarliy offset, and an angle reset commands at the start
  169. // of each level and after teleporting.
  170.     vec3_t        mviewangles[2];    // during demo playback viewangles is lerped
  171.                                 // between these
  172.     vec3_t        viewangles;
  173.     
  174.     vec3_t        mvelocity[2];    // update by server, used for lean+bob
  175.                                 // (0 is newest)
  176.     vec3_t        velocity;        // lerped between mvelocity[0] and [1]
  177.  
  178.     vec3_t        punchangle;        // temporary offset
  179.     
  180. // pitch drifting vars
  181.     float        idealpitch;
  182.     float        pitchvel;
  183.     qboolean    nodrift;
  184.     float        driftmove;
  185.     double        laststop;
  186.  
  187.     float        viewheight;
  188.     float        crouch;            // local amount for smoothing stepups
  189.  
  190.     qboolean    paused;            // send over by server
  191.     qboolean    onground;
  192.     qboolean    inwater;
  193.     
  194.     int            intermission;    // don't change view angle, full screen, etc
  195.     int            completed_time;    // latched at intermission start
  196.     
  197.     double        mtime[2];        // the timestamp of last two messages    
  198.     double        time;            // clients view of time, should be between
  199.                                 // servertime and oldservertime to generate
  200.                                 // a lerp point for other data
  201.     double        oldtime;        // previous cl.time, time-oldtime is used
  202.                                 // to decay light values and smooth step ups
  203.     
  204.  
  205.     float        last_received_message;    // (realtime) for net trouble icon
  206.  
  207. //
  208. // information that is static for the entire time connected to a server
  209. //
  210.     struct model_s        *model_precache[MAX_MODELS];
  211.     struct sfx_s        *sound_precache[MAX_SOUNDS];
  212.  
  213.     char        levelname[40];    // for display on solo scoreboard
  214.     int            viewentity;        // cl_entitites[cl.viewentity] = player
  215.     int            maxclients;
  216.     int            gametype;
  217.  
  218. // refresh related state
  219.     struct model_s    *worldmodel;    // cl_entitites[0].model
  220.     struct efrag_s    *free_efrags;
  221.     int            num_entities;    // held in cl_entities array
  222.     int            num_statics;    // held in cl_staticentities array
  223.     entity_t    viewent;            // the gun model
  224.  
  225.     int            cdtrack, looptrack;    // cd audio
  226.  
  227. // frag scoreboard
  228.     scoreboard_t    *scores;        // [cl.maxclients]
  229.  
  230. #ifdef QUAKE2
  231. // light level at player's position including dlights
  232. // this is sent back to the server each frame
  233. // architectually ugly but it works
  234.     int            light_level;
  235. #endif
  236. } client_state_t;
  237.  
  238.  
  239. //
  240. // cvars
  241. //
  242. extern    cvar_t    cl_name;
  243. extern    cvar_t    cl_color;
  244.  
  245. extern    cvar_t    cl_upspeed;
  246. extern    cvar_t    cl_forwardspeed;
  247. extern    cvar_t    cl_backspeed;
  248. extern    cvar_t    cl_sidespeed;
  249.  
  250. extern    cvar_t    cl_movespeedkey;
  251.  
  252. extern    cvar_t    cl_yawspeed;
  253. extern    cvar_t    cl_pitchspeed;
  254.  
  255. extern    cvar_t    cl_anglespeedkey;
  256.  
  257. extern    cvar_t    cl_autofire;
  258.  
  259. extern    cvar_t    cl_shownet;
  260. extern    cvar_t    cl_nolerp;
  261.  
  262. extern    cvar_t    cl_pitchdriftspeed;
  263. extern    cvar_t    lookspring;
  264. extern    cvar_t    lookstrafe;
  265. extern    cvar_t    sensitivity;
  266.  
  267. extern    cvar_t    m_pitch;
  268. extern    cvar_t    m_yaw;
  269. extern    cvar_t    m_forward;
  270. extern    cvar_t    m_side;
  271.  
  272.  
  273. #define    MAX_TEMP_ENTITIES    64            // lightning bolts, etc
  274. #define    MAX_STATIC_ENTITIES    128            // torches, etc
  275.  
  276. extern    client_state_t    cl;
  277.  
  278. // FIXME, allocate dynamically
  279. extern    efrag_t            cl_efrags[MAX_EFRAGS];
  280. extern    entity_t        cl_entities[MAX_EDICTS];
  281. extern    entity_t        cl_static_entities[MAX_STATIC_ENTITIES];
  282. extern    lightstyle_t    cl_lightstyle[MAX_LIGHTSTYLES];
  283. extern    dlight_t        cl_dlights[MAX_DLIGHTS];
  284. extern    entity_t        cl_temp_entities[MAX_TEMP_ENTITIES];
  285. extern    beam_t            cl_beams[MAX_BEAMS];
  286.  
  287. //=============================================================================
  288.  
  289. //
  290. // cl_main
  291. //
  292. dlight_t *CL_AllocDlight (int key);
  293. void    CL_DecayLights (void);
  294.  
  295. void CL_Init (void);
  296.  
  297. void CL_EstablishConnection (char *host);
  298. void CL_Signon1 (void);
  299. void CL_Signon2 (void);
  300. void CL_Signon3 (void);
  301. void CL_Signon4 (void);
  302.  
  303. void CL_Disconnect (void);
  304. void CL_Disconnect_f (void);
  305. void CL_NextDemo (void);
  306.  
  307. #define            MAX_VISEDICTS    256
  308. extern    int                cl_numvisedicts;
  309. extern    entity_t        *cl_visedicts[MAX_VISEDICTS];
  310.  
  311. //
  312. // cl_input
  313. //
  314. typedef struct
  315. {
  316.     int        down[2];        // key nums holding it down
  317.     int        state;            // low bit is down state
  318. } kbutton_t;
  319.  
  320. extern    kbutton_t    in_mlook, in_klook;
  321. extern     kbutton_t     in_strafe;
  322. extern     kbutton_t     in_speed;
  323.  
  324. void CL_InitInput (void);
  325. void CL_SendCmd (void);
  326. void CL_SendMove (usercmd_t *cmd);
  327.  
  328. void CL_ParseTEnt (void);
  329. void CL_UpdateTEnts (void);
  330.  
  331. void CL_ClearState (void);
  332.  
  333.  
  334. int  CL_ReadFromServer (void);
  335. void CL_WriteToServer (usercmd_t *cmd);
  336. void CL_BaseMove (usercmd_t *cmd);
  337.  
  338.  
  339. float CL_KeyState (kbutton_t *key);
  340. char *Key_KeynumToString (int keynum);
  341.  
  342. //
  343. // cl_demo.c
  344. //
  345. void CL_StopPlayback (void);
  346. int CL_GetMessage (void);
  347.  
  348. void CL_Stop_f (void);
  349. void CL_Record_f (void);
  350. void CL_PlayDemo_f (void);
  351. void CL_TimeDemo_f (void);
  352. void CL_TimeDemo2_f (void);
  353.  
  354. //
  355. // cl_parse.c
  356. //
  357. void CL_ParseServerMessage (void);
  358. void CL_NewTranslation (int slot);
  359.  
  360. //
  361. // view
  362. //
  363. void V_StartPitchDrift (void);
  364. void V_StopPitchDrift (void);
  365.  
  366. void V_RenderView (void);
  367. void V_UpdatePalette (void);
  368. void V_Register (void);
  369. void V_ParseDamage (void);
  370. void V_SetContentsColor (int contents);
  371.  
  372.  
  373. //
  374. // cl_tent
  375. //
  376. void CL_InitTEnts (void);
  377. void CL_SignonReply (void);
  378.